package com.voda.dao.api;

import java.util.List;

import javax.persistence.PersistenceException;

import com.voda.entity.api.IBaseEntity;

public interface IGenericDao<T extends IBaseEntity> {

	/**
	 * Adds the record to database.
	 *
	 * @param entity the entity
	 * @return the integer - unique identifier of created entity
	 * @throws PersistenceException the persistence exception
	 */
	public Long addRecord(T entity) throws PersistenceException;
	
	/**
	 * Delete record from database.
	 *
	 * @param id - entity unique identifier
	 * @throws PersistenceException the persistence exception
	 */
	public void deleteRecord(Long id) throws PersistenceException;
	
	/**
	 * Update record in database.
	 *
	 * @param entity - the entity to update
	 * @throws PersistenceException the persistence exception
	 */
	public void updateRecord(T entity) throws PersistenceException;
	
	/**
	 * Gets the record by id from database.
	 *
	 * @param id - entity unique identifier
	 * @return the record - entity with filled fields and relations
	 * @throws PersistenceException the persistence exception
	 */
	public T getRecordById(Long id) throws PersistenceException;
	
	/**
	 * Collects all entities from database and returns list.
	 *
	 * @param startPage the start page
	 * @param pageSize the page size
	 * @return the records page
	 * @throws PersistenceException the persistence exception
	 */
	public List<T> getRecordsPage(Integer startPage, Integer pageSize) throws PersistenceException;
	
	/**
	 * Count.
	 *
	 * @return the integer
	 */
	public Integer count() throws PersistenceException;

	/**
	 * Gets the all.
	 *
	 * @return the all
	 */
	public List<T> getAll() throws PersistenceException;
}
